<script setup lang="ts">
import { NButton, NRow, useMessage } from 'naive-ui'
import { ref } from 'vue';
import { test } from '../api/test'

const $message = useMessage()

const reqRes = ref<any>() // 请求结果

async function getTestRes() {
  try {
    const res = await test({})
    console.log(res)
    if (res.code !== 200) throw new Error(JSON.stringify(res))
    reqRes.value = res.data
    $message.success('请求成功')
  } catch (error) {
    console.log(error);
    $message.error('请求失败')
  }
}
</script>

<template>
  <div class="Test">
    <n-row justify-content="flex-end">
      <n-button type="primary" @click="getTestRes">开始测试</n-button>
    </n-row>
    <pre>{{ reqRes }}</pre>
  </div>
</template>

<style scoped>
.Test {
  padding: 0.5rem;
}
</style>
